package collection.homework.Collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * 增强for循环/新循环
 */
public class NewForDemo {
    public static void main(String[] args) {
        String[] array = {"one","two","three","four"};
        for (int i = 0;i< array.length;i++){
            System.out.println(array[i]);
        }
        for (String str:array){
            System.out.println(str);
        }

        Collection<String> b = new ArrayList<>();
        b.add("one");
        b.add("two");
        b.add("three");
        b.add("four");

        Iterator<String> it = b.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        for (String str : b){
            System.out.println(str);
        }
    }
}
